<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

namespace app\index\controller;
use app\common\controller\HomeBase;
use think\Db;
use think\Request;

/**
 * Description of Analysis
 *
 * @author maylor
 */
class Analysis extends HomeBase{
    //put your code here
    
    protected function _initialize() {
        parent::_initialize();
        $this->assign('this_controller','analysis');
    }
    
    public function index(Request $request) {
        $id = $request->param('id');
        if(!empty($id)) {
             $data = Db::name('article')->where(['cid'=>1,'status'=>1,'id'=>$id])->find();
        }else {
             $data = Db::name('article')->where(['cid'=>1,'status'=>1])->order('id asc')->find();
        }
        if(!empty($data['photo'])) {
            $data['photo'] = unserialize($data['photo']);
        }
        $this->assign('data',$data);
        return $this->fetch();
    }
    
    public function detail($id) {
        $data = Db::name('article')->where(['cid'=>1,'status'=>1,'id'=>$id])->find();
        $this->assign('data',$data);
        return $this->fetch();
    }
}
